<template>
  <div class="center">
    <!-- <barChart :option="option" height="100%" /> -->
    <dv-percent-pond
      :config="config"
      style="width: 350px; height: 200px"
      class="electronA"
    />
    <dv-percent-pond
      :config="config2"
      style="width: 350px; height: 200px"
      class="electronB"
    />
    <div class="A-postion">
      <div class="B-text">{{ config.value }}%</div>
      <div class="B-text">{{ config2.value }}%</div>
    </div>
    <div class="B-postion">
      <div class="B-text-name">钢化前理片</div>
      <div class="B-text-name">中空前理片</div>
    </div>
  </div>
</template>

<script>
import DecTitle from "@/components/decTitle";
import barChart from "@/components/echart/barChart";
import { option2 } from "./option";
import { mapState } from "vuex";
export default {
  components: {
    DecTitle,
    barChart,
  },
  data() {
    return {
      option: null,
      // config: {
      //   value: 60,
      //   borderWidth: 5,
      //   borderRadius: 10,
      //   borderGap: 5,
      //   // colors: ['#01c4f9', '#fcc524','red'],
      // },
      // config2: {
      //   value: 30,
      //   borderWidth: 5,
      //   borderRadius: 10,
      //   borderGap: 5,
      // },
      rate2: 65,
    };
  },
  methods: {
    handlerdata() {
      let useValue = this.glassList.length;
      let noUseValue = 350 - useValue;

      let optionData = option();
      optionData.color = ["#7ed3f4", this.prenctColor];
      optionData.series[0].data = [
        {
          name: "未使用",
          value: noUseValue,
        },
        {
          name: "已使用",
          value: useValue,
        },
      ];
      this.option = optionData;
    },
  },
  created() {},
  mounted() {},
  computed: {
    ...mapState({
      glassList(state) {
        return state.Glass.glass.filter((item) => item.place == 146);
      },
    }),
    rate() {
      // return Math.floor((this.glassList.length / 350).toFixed(2) * 100);
      return 16
    },
    prenctColor() {
      if (this.rate <= 60) return ["#38e4cd"];
      if (this.rate > 60 && this.rate < 80) return ["#38e4cd", "#fcc525"];
      if (this.rate >= 80) return ["#38e4cd", "#fcc525", "red"];
    },
    prenctColor2() {
      if (this.rate2 <= 60) return ["#38e4cd"];
      if (this.rate2 > 60 && this.rate < 80) return ["#38e4cd", "#fcc525"];
      if (this.rate2 >= 80) return ["#38e4cd", "#fcc525", "red"];
    },
    config() {
      return {
        value: this.rate,
        borderWidth: 5,
        borderRadius: 10,
        borderGap: 5,
        colors: this.prenctColor,
      };
    },
    config2() {
      return {
        value: this.rate2,
        borderWidth: 5,
        borderRadius: 10,
        borderGap: 5,
        colors: this.prenctColor2,
      };
    },
  },
};
</script>

<style lang="scss" scoped>
.center {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-around;
  //   color: #e6e6e6;
  .electronA,
  .electronB {
    transform: rotate(-90deg);
  }
  .A-postion {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-around;
    .B-text {
      font-size: 36px;
      font-weight: bold;
    }
  }
  .B-postion {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 20%;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    .B-text-name {
      font-size: 24px;
      font-weight: bold;
    }
  }
}
::v-deep .el-progress-circle {
  width: 300px;
  height: 300px;
  color: #fff;
  font-size: 36px;
  font-weight: bold;
}
::v-deep .dv-percent-pond text {
  display: none;
}
</style>